<!DOCTYPE html>

<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>宠物医院</title>
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/css/dashboard.css}" rel="stylesheet">
    <link th:href="@{/img/pet2.jpg}" rel="shortcut icon">
</head>
<body>

<!--顶部导航栏-->
<div th:replace="~{comment/comment::topbar}"></div>
<div class="container-fluid">
    <div class="row">
        <!--侧边导航栏-->
        <div th:replace="~{comment/comment::sidebar(active='pet/petInfo.html')}"></div>
        <!--主视图-->
        <main role="main" class="col-md-9 ml-sm-auto col-lg-11 pt-3 px-4">
           <!--表单-->
            <form th:action="@{/savePet}" method="post">
                <div class="form-group">
                  <label>姓名</label>
                  <input type="text" class="form-control" name="pName">
                </div>
                <div class="form-group">
                  <label>年龄</label>
                  <input type="text" class="form-control" name="pAge">
                </div>
                <div class="form-group">
                  <label>性别</label><br/>
                  <div class="form-check form-check-inline">
                   <input class="form-check-input" type="radio" name="pSex" value="1">
                   <label class="form-check-label">公</label>
                  </div>
                  <div class="form-check form-check-inline">
                    <input class="form-check-input" type="radio" name="pSex" value="0">
                    <label class="form-check-label">母</label>
                  </div>
                </div>
                <div class="form-group">
                    <label>病情</label>
                    <input type="text" class="form-control" name="illness">
                </div>
                <div class="form-group">
                    <label>主人</label>
                    <input type="text" class="form-control" name="master">
                </div>
                <div class="form-group">
                    <label>科室</label>
                    <select class="form-control" name="pSickroom" id="pSickroom">
                      <option th:each="s:${sickrooms}"  th:text="${s.getSickroomName()}" th:value="${s.getSickroomName()}"></option>
                    </select>
                </div>
                <div class="form-group">
                    <label>医生</label>
                    <select class="form-control" name="pDoctor" id="pDoctor">
                        <option th:each="d:${doctors}" th:text="${d.getdName()}" th:value="${d.getdName()}"></option>
                    </select>
                </div>
                <div class="row">
                    <div class="col-md-11 column">
                        <button type="submit" class="btn btn-primary">提交</button>
                    </div>
                    <div class="col-md-1 column">
                        <a class="btn btn-primary" th:href="@{/getPets}">返回</a>
                    </div>
                </div>
            </form>
        </main>
    </div>
</div>
<script type="text/javascript" th:src="@{/js/jquery-3.4.1.min.js}"></script>
<script>
    function select() {
        var p = $("#pSickroom").val();
        $.ajax({
            type:"GET",
            url:"/selectDoctor/" + p,
            async:true,
            success:function (data) {
                var rList = data;
                var rSelect = "<option>——请选择医生——</option>";
                for(var i = 0; i < rList.length; i++){
                    rSelect += ("<option value = '"+rList[i].doctor+"'>"+rList[i].doctor+"</option>");
                }
                $("#pDoctor").empty();
                $("#pDoctor").append(rSelect);
            }
        })
    }



</script>
</body>

</html>